package com.yidu.t299.dao.fxj;

import com.yidu.t299.domain.fxj.ClassRoom;
import org.apache.ibatis.annotations.*;
import java.util.List;

@Mapper
public interface ClassRoomMapper {
    /**
     * 删
     * @return 影响的行数(返回1则为成功)
     */
    @Delete({
            "delete from classroom" +
                    " where classroom_id = #{classRoomId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer classRoom_id);

    /**
     * 添加
     * @return 影响的行数(返回1则为成功)
     */
    @Insert({
            "insert into classroom (classRoom_id, classRoom_name)" +
                    " values (#{classRoomId,jdbcType=INTEGER}, #{classRoomName,jdbcType=VARCHAR})"
    })
    int insert(ClassRoom classRoom);

    /**
     * 根据编号查询指定的信息
     * @return 校区对象
     */
    @Select({
            "select" +
                    " classRoom_id, classRoom_name" +
                    " from classroom" +
                    " where classRoom_id = #{classRoomId,jdbcType=INTEGER}"
    })
    @Results(id = "classroom",value = {
            @Result(id = true,column = "classRoom_id",property = "classRoomId"),
            @Result(column = "classRoom_name",property = "classRoomName")
    })
    ClassRoom selectByPrimaryKey(Integer classRoomId);

    /**
     * 按条件分页查询校区数据集合
     * @param rows 每页的行数
     * @param page 页码
     * @param condition 条件参数
     * @return 校区对象集合
     */
    @Select("select * from classroom where 1=1 ${condition} limit #{page},#{rows}")
    @ResultMap("classroom")
    List<ClassRoom> selectByPage(@Param("rows") int rows, @Param("page") int page, @Param("condition") String condition);

    /**
     * 按条件查询表中数据行数
     * @param condition 条件参数
     * @return 数据行数
     */
    @Select("select count(*) from classroom where 1=1 ${condition}")
    int selectCount(@Param("condition") String condition);

    /**
     * 根据信息修改其数据
     * @return 影响的行数(返回1则为成功)
     */
    @Update({
            "update classroom",
            " set classRoom_name = #{classRoomName,jdbcType=VARCHAR}",
            " where classRoom_id = #{classRoomId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(ClassRoom classRoom);
}
